package com.inei.cie;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.inei.cie.utilitarios.Variables;

public class BPR_Activity extends Activity {
	
	public WebView wvBPR;
	public Bundle b;
	public Variables var;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.visualizador_web);
		IniciarComponentes();

	}

	public void IniciarComponentes() {
		b = getIntent().getExtras();

		var = new Variables();

		// setTitle("DNI: " + b.getString(var.DNI));
		setTitle("Banco de Preguntas y Respuestas");

		wvBPR = (WebView) findViewById(R.id.wvWeb);
		WebSettings settings = wvBPR.getSettings();
		settings.setDisplayZoomControls(true);
		settings.setLoadWithOverviewMode(false);
		settings.setSupportZoom(true);
		settings.setBuiltInZoomControls(true);
		settings.setJavaScriptEnabled(true);

		wvBPR.setWebViewClient(new WebViewClient());
		wvBPR.loadUrl("http://www.gmail.com");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_atras, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.mnSalir:
			AlertDialog.Builder dialogo1 = new AlertDialog.Builder(this);
			dialogo1.setTitle("Importante");
			dialogo1.setMessage("Deseas Salir ?");
			dialogo1.setIcon(android.R.drawable.ic_dialog_alert);
			dialogo1.setCancelable(false);
			dialogo1.setPositiveButton("Si",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialogo1, int id) {
						System.exit(0);
					}
				});

			dialogo1.setNegativeButton("No",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialogo1, int id) {
							return;
						}
					});
			dialogo1.show();
			break;
		case R.id.mnMarco:
			Intent irCarga = new Intent(this, Carga_Trabajo_Activity.class);
			irCarga.putExtras(b);
			startActivity(irCarga);
			finish();
			break;

		default:
			break;
		}
		return super.onOptionsItemSelected(item);

	}

	@Override
	public void onBackPressed() {
		Intent irCarga = new Intent(this, Carga_Trabajo_Activity.class);
		irCarga.putExtras(b);
		startActivity(irCarga);
		finish();
	}

}
